const app = getApp()
Page({

  data: {
    userInfo:{},
  },

  onLoad: function () {
    // let that = this;
    // let userinfo = wx.getStorageSync('userinfo')
    // console.log(userinfo)
    // that.setData({
    //   avatarUrl:user_info.avatarUrl,
    //   nickName:user_info.nickName
    // })
    app.getUser()
    console.log(app.globalData.userInfo)
    if(app.globalData.userInfo){
      this.setData({
        userInfo:app.globalData.userInfo
      })
    }
  },

  onShow(){
    let access_token = wx.getStorageSync('access_token')
    wx.request({
      url: 'https://baokang.wshoto.com/wx/checkauth',
      data: {
        access_token: access_token
      },
      success: (res) => {
        console.log(res)
        if(res.data.code >= 500){
          app.getLogin().then(function(){
            console.log('二次登录。。。')
          })
        }
        else if (res.data.code == 1) {
          this.setData({
            duty:res.data.duty,
            c_name:res.data.c_name,
            g_name:res.data.g_name
          })
        }
      }
    })
  },
  
  house(){
    wx.navigateTo({
      url: '../house-table/house-table?c_name=' + this.data.c_name + '&g_name=' + this.data.g_name,
    })
  },
  population(){
    wx.navigateTo({
      url: '../population-table/population-table?c_name=' + this.data.c_name + '&g_name=' + this.data.g_name,
    })
  },
  special(){
    wx.navigateTo({
      url: '../special/special'
    })
  },
  unit(){
    wx.navigateTo({
      url: '../unit-table/unit-table?c_name=' + this.data.c_name + '&g_name=' + this.data.g_name,
    })
  },
  hospital(){
    wx.navigateTo({
      url: '../hospital-table/hospital-table?c_name=' + this.data.c_name + '&g_name=' + this.data.g_name,
    })
  },
  school(){
    wx.navigateTo({
      url: '../school-table/school-table?c_name=' + this.data.c_name + '&g_name=' + this.data.g_name,
    })
  }
})